from openpyxl import load_workbook,Workbook
import flet as fl
def main(page:fl.Page):
    page.title="加班查询"
    page_width=300
    page_height=160
    page.window.height = page_height
    page.window.width = page_width
    page.window.resizable = False
    page.horizontal_alignment = fl.CrossAxisAlignment.CENTER
    def do_file(e):
        x=input.value
        btn.text="开始读取add_data.xlsx"
        wb=load_workbook("d:/加班.xlsx")
        final=[]
        for sheet in wb:
            for row in range(2,sheet.max_row+1):
                if sheet.cell(row,1).value==x:
                    local=[sheet.title,sheet.cell(row, 3).value]
                    final.append(local)
        wb.close()
        ww=Workbook()
        wws=ww.active
        wws.append(["日期","加班时数"])
        for i in final:
            wws.append(i)
        ww.save('d:/查询结果_'+x+'.xlsx')
    input=fl.TextField(label="请输入工号",width=200)
    btn=fl.ElevatedButton(text="查询",on_click=do_file,width=200)
    page.add(input,btn)
fl.app(target=main)